#include "QuaternionViewer.h"

void QuaternionViewer::Draw()
{
	glBegin(GL_LINES);
	//	glColor3f(0,1,0);	glVertex3f(0,0,0);	//point 1
	//						glVertex3f(m_position.x,m_position.y,m_position.z);	//point 2
		glColor3f(0,0,1);	glVertex3f(0,0,0);	//point 1 axe y
	//						glVertex3f(0,100,0);	//point 2 axe y
	//						glVertex3f(0,0,0);	//point 1 axe x
							glVertex3f(100,0,0);	//point 2 axe x
	//						glVertex3f(0,0,0);	//point 1 axe z
	//						glVertex3f(0,0,100);	//point 2 axe z
	glEnd();
	glTranslatef(m_position.x,m_position.y,m_position.z);
	GraphicSphere::Draw(2.5);
}

void QuaternionViewer::Compute(float angleX, float angleY, float angleZ)
{
	Quaternion q1 = Quaternion(Vector3(1,0,0),angleX);
	Quaternion q2 = Quaternion(Vector3(0,1,0),angleY);
	Quaternion q3 = Quaternion(Vector3(0,0,1),angleZ);

	m_rotation = q1 * q2 * q3;

	m_position = m_rotation.rotate(m_position);
}

void QuaternionViewer::Compute(float angleX, float angleY, float angleZ, Joint* joint)
{
	Quaternion q1 = Quaternion(Vector3(1,0,0),angleX);
	Quaternion q2 = Quaternion(Vector3(0,1,0),angleY);
	Quaternion q3 = Quaternion(Vector3(0,0,1),angleZ);

	m_rotation = q1 * q2 * q3;

	m_position = m_rotation.rotate(m_position);

	joint->m_translation = m_position;
	joint->m_rotation = m_rotation;

}